package com.ibeeking.found.cop.b.rest.controller.v1;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ibeeking.found.cop.b.rest.service.IKfWikiGroupService;
import com.ibeeking.found.cop.b.rest.service.IKfWikiService;
import com.ibeeking.found.cop.service.common.param.KfWikiGroupParam;
import com.ibeeking.found.cop.service.common.param.KfWikiParam;
import com.ibeeking.found.cop.service.common.query.KfWikiGroupQuery;
import com.ibeeking.found.cop.service.common.query.KfWikiPageQuery;
import com.ibeeking.found.cop.service.common.query.KfWikiQuery;
import com.ibeeking.found.cop.service.common.vo.KfFriendsMessageVO;
import com.ibeeking.found.cop.service.common.vo.KfWikiGroupVO;
import com.ibeeking.found.cop.service.common.vo.KfWikiVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName KfAutoReplyController
 * @Description
 * @Author ibeeking
 * @Date 2021-06-02 18:15
 **/
@RestController
@RequestMapping("/b/kfAutoReply/v1")
public class KfAutoReplyController {

    @Resource
    private IKfWikiGroupService kfWikiGroupServiceImpl;

    @Resource
    private IKfWikiService kfWikiServiceImpl;

    /*
     ** 知识库分组
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询知识库分组列表树")
    @PostMapping(value = "/wikiGroupTreeList/{parentId}")
    public List<KfWikiGroupVO> wikiTreeList(@PathVariable("parentId") Long parentId) {
        List<KfWikiGroupVO>  groupVOS = kfWikiGroupServiceImpl.listByParentId(parentId);
        return groupVOS;
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询知识库分组列表")
    @PostMapping(value = "/wikiGroupList")
    public List<KfWikiGroupVO> wikiList(@RequestBody KfWikiGroupQuery query) {
        return kfWikiGroupServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "添加知识库分组")
    @PostMapping(value = "/wikiGroupAdd")
    public Boolean wikiGroupAdd(@RequestBody @Validated(BaseValidationGroup.Insert.class) KfWikiGroupParam param) {
        return kfWikiGroupServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改知识库分组")
    @PostMapping(value = "/wikiGroupModify")
    public Boolean wikiGroupModify(@RequestBody @Validated(BaseValidationGroup.Update.class) KfWikiGroupParam param) {
        return kfWikiGroupServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看知识库分组详情")
    @GetMapping(value = "/wikiGroupView/{id}")
    public KfWikiGroupVO wikiGroupView(@PathVariable("id") Long id) {
        return kfWikiGroupServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除知识库分组")
    @GetMapping(value = "/wikiGroupDel/{id}")
    public Boolean wikiGroupDel(@PathVariable("id") Long id) {
        return kfWikiGroupServiceImpl.del(id);
    }

    /*
     ** 知识库
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询知识库列表")
    @PostMapping(value = "/wikiList")
    public List<KfWikiVO> list(@RequestBody KfWikiQuery query) {
        return kfWikiServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询知识库分页列表")
    @PostMapping(value = "/wikiPageList")
    public Page<KfWikiVO> pageList(@RequestBody KfWikiPageQuery pageQuery) {
        return kfWikiServiceImpl.pageList(pageQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询常见问题列表")
    @PostMapping(value = "/listMarkCommon")
    public List<KfWikiVO> listMarkCommon() {
        return kfWikiServiceImpl.listMarkCommon();
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "添加知识库")
    @PostMapping(value = "/wikiAdd")
    public Boolean add(@RequestBody @Validated(BaseValidationGroup.Insert.class) KfWikiParam param) {
        return kfWikiServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改知识库")
    @PostMapping(value = "/wikiModify")
    public Boolean modify(@RequestBody @Validated(BaseValidationGroup.Update.class) KfWikiParam param) {
        return kfWikiServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改是否启用")
    @GetMapping(value = "/changeWikiStatus/{id}/{status}")
    public Boolean changeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return kfWikiServiceImpl.changeStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看知识库详情")
    @GetMapping(value = "/wikiView/{id}")
    public KfWikiVO view(@PathVariable("id") Long id) {
        return kfWikiServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除知识库")
    @GetMapping(value = "/wikiDel/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return kfWikiServiceImpl.del(id);
    }

}
